package hot100;

public class Solution114 {
    public void flatten(TreeNode root) {
        if (root == null) return;
        TreeNode left = root.left;
        flatten(left);
        root.left = null;
        TreeNode right = root.right;
        flatten(right);
        root.right = left;
        TreeNode tmp = root;
        while (tmp.right != null) tmp = tmp.right;
        tmp.right = right;
    }
}
